package com.wiretrack.circuit;

import java.io.IOException;

import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteException;
import org.apache.log4j.Logger;

public class SoundPlayer extends Thread
{
	private static Logger log = Logger.getLogger(SoundPlayer.class.getName());
	private String commandToExecute;
	public SoundPlayer(String cmd)
	{
		commandToExecute = cmd;
	}
	public void run()
	{
		log.debug("Executing: " + commandToExecute);
		
		CommandLine cmdLine = CommandLine.parse(commandToExecute);
		DefaultExecutor executor = new DefaultExecutor();
		int exitValue;
		
		try
		{
			exitValue = executor.execute(cmdLine);
			log.debug("Exit value after playing sound: " + exitValue);
		}
		catch (ExecuteException e)
		{
			e.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}
